Processor with variable pre-fetch threshold

ABSTRACT

A method and apparatus for controlling pre-fetching in a processor. A processor includes an execution pipeline and an instruction pre-fetch unit. The execution pipeline is configured to execute instructions. The instruction pre-fetch unit is coupled to the execution pipeline. The instruction pre-fetch unit includes instruction storage to store pre-fetched instructions, and pre-fetch control logic. The pre-fetch control logic is configured to fetch instructions from memory and store the fetched instructions in the instruction storage. The pre-fetch control logic is also configured to provide instructions stored in the instruction storage to the execution pipeline for execution. The pre-fetch control logic is further configured set a maximum number of instruction words to be pre-fetched for execution subsequent to execution of an instruction currently being executed in the execution pipeline. The maximum number is based on a value contained in a pre-fetch threshold field of an instruction executed in the execution pipeline.

BACKGROUND

Conditional constructs, such “if-then” and “if-then-else” are commonlyused in programming to control the sequence of instruction execution.Such constructs are typically implemented using conditional jump orbranch instructions. In pipelined processors jump and branchinstructions can cause control hazards. That is, immediately after thejump or branch instruction enters the execution pipeline, subsequentinstructions are not executed. Instead, a condition specified by thejump or branch instruction is evaluated (to determine whether toredirect program flow) and if the condition is satisfied, then theinstruction at a destination address specified by the jump or branchinstruction is fetched. Depending on the system architecture (pipelinedepth, instruction bus/memory latency) the number of cycles the pipelineis stalled to resolve the hazard can vary. Stalling reduced processorperformance.

Because many if-then and if-then-else instruction sequences include onlya few instructions per branch, a pre-fetch buffer that containsinstructions fetched in advance serves as a way to reduce the stallcycles caused by conditional constructs. If the target instruction of abranch or jump has been pre-fetched, the target instruction can be readfrom the pre-fetch buffer instead of fetching the instruction frommemory. Thus, pre-fetching can reduce the number of stall cyclesassociated with conditional execution and increase overall processorperformance.

SUMMARY

A method and apparatus for controlling pre-fetching in a processor aredisclosed herein. In one embodiment, a processor includes an executionpipeline and an instruction pre-fetch unit. The execution pipeline isconfigured to execute instructions. The instruction pre-fetch unit iscoupled to the execution pipeline. The instruction pre-fetch unitincludes instruction storage to store pre-fetched instructions, andpre-fetch control logic. The pre-fetch control logic is configured tofetch instructions from memory and store the fetched instructions in theinstruction storage. The pre-fetch control logic is also configured toprovide instructions stored in the instruction storage to the executionpipeline for execution. The pre-fetch control logic is furtherconfigured selectably set a maximum number of instruction words to bepre-fetched for execution subsequent to execution of an instructioncurrently being executed in the instruction pipeline. The maximum numberis based on a value contained in a pre-fetch threshold field of aninstruction executed in the execution pipeline.

In another embodiment, a method includes pre-fetching, by a processor,instructions from an instruction memory; storing, by the processor, thepre-fetched instructions in a pre-fetch buffer; reading, by theprocessor, the pre-fetched instructions from the pre-fetch buffer; andproviding, by the processor, the read instructions to an executionpipeline for execution. The method also includes varying, by theprocessor, a number of instruction words to be pre-fetched for executionsubsequent to execution of an instruction currently being executed inthe instruction pipeline. The varying is based on a value contained in apre-fetch threshold field of an instruction executed in the executionpipeline.

In further embodiment, an instruction pre-fetch unit includesinstruction storage for storing pre-fetched instructions, and pre-fetchcontrol logic. The pre-fetch control logic is configured to fetchinstructions from memory and store the fetched instructions in theinstruction storage. The pre-fetch control logic is also configured toprovide instructions stored in the instruction storage to an executionpipeline for execution. The pre-fetch control logic is furtherconfigured to selectably set a maximum number of instruction words to bepre-fetched for execution subsequent to execution of an instructioncurrently being executed in the instruction pipeline. The maximum numberis based on a value contained in a pre-fetch threshold field of aninstruction executed in the execution pipeline.

In a yet further embodiment, a non-transitory computer-readable mediumencoded with instructions that when executed cause a computer toidentify a jump instruction in a set of instructions. A destinationinstruction in the set of instructions corresponding to the jumpinstruction is identified. A distance between the jump instruction andthe destination instruction is computed. Based on the distance, aninstruction that sets a maximum number of instruction words to bepre-fetched as the jump instruction is executed by a target processorthat executes the set of instructions is inserted into the set ofinstructions.

BRIEF DESCRIPTION OF THE DRAWINGS

For a detailed description of exemplary embodiments of the invention,reference will now be made to the accompanying drawings in which:

FIG. 1 shows a block diagram of a processor in accordance with variousembodiments;

FIG. 2 shows a block diagram of a pre-fetch unit in accordance withvarious embodiments;

FIG. 3 shows an exemplary instruction for controlling pre-fetchthreshold in accordance with various embodiments;

FIG. 4 shows an instruction sequence that includes a pre-fetch thresholdset to optimize performance in accordance with various embodiments;

FIG. 5 shows an instruction sequence that includes a pre-fetch thresholdset to reduce pre-fetch energy use in accordance with variousembodiments;

FIG. 6 shows a flow diagram for a method for controlling pre-fetchthreshold in accordance with various embodiments; and

FIG. 7 shows a block diagram of a system for setting pre-fetchthresholds in a set of instructions under development in accordance withvarious embodiments.

NOTATION AND NOMENCLATURE

Certain terms are used throughout the following description and claimsto refer to particular system components. As one skilled in the art willappreciate, companies may refer to a component by different names. Thisdocument does not intend to distinguish between components that differin name but not function. In the following discussion and in the claims,the terms “including” and “comprising” are used in an open-endedfashion, and thus should be interpreted to mean “including, but notlimited to . . . .” Also, the term “couple” or “couples” is intended tomean either an indirect or direct electrical connection. Thus, if afirst device couples to a second device, that connection may be througha direct electrical connection, or through an indirect electricalconnection via other devices and connections. The recitation “based on”is intended to mean “based at least in part on.” Therefore, if X isbased on Y, X may be based on Y and any number of additional factors.

The terms “branch” and “jump” are used herein as equivalents to refer toa discontinuity in instruction retrieval and execution. Accordingly, theterms “jump instruction” and “branch instruction” are usedinterchangeably.

DETAILED DESCRIPTION

The following discussion is directed to various embodiments of theinvention. Although one or more of these embodiments may be preferred,the embodiments disclosed should not be interpreted, or otherwise used,as limiting the scope of the disclosure, including the claims. Inaddition, one skilled in the art will understand that the followingdescription has broad application, and the discussion of any embodimentis meant only to be exemplary of that embodiment, and not intended tointimate that the scope of the disclosure, including the claims, islimited to that embodiment.

While pre-fetching can increase processor performance by reducingpipeline stalls associated with conditional constructs or instructionmemory latency in linear code, pre-fetching is not without its issues.The higher the number of instructions pre-fetched, the higher thelikelihood that the pre-fetch buffer contains the target instruction ofan executed jump or branch. Accordingly, some conventional processorspre-fetch as many instructions as possible. Unfortunately, if thedestination instruction referenced by a jump or branch is too distantfrom the jump or branch instruction, the destination instruction willnot be stored in the pre-fetch buffer, and because memory accesses aretypically energy intensive, the pre-fetching will have wastedsubstantial energy retrieving instructions from memory that will not beexecuted. Energy consumption may be reduced by pre-fetching fewerinstructions. In conventional processors, pre-fetch buffer size isdetermined as a compromise between performance and energy optimization.

Embodiments of the present disclosure include a dynamically variablepre-fetch threshold. The pre-fetch threshold determines the number ofinstructions pre-fetched and stored in the pre-fetch buffer, and varyingthe pre-fetch threshold allows the number of instructions pre-fetchedand stored in the pre-fetch buffer to vary under instruction control.When a portion of the instruction stream including conditionalconstructs for which the destination instruction of a jump or branch islikely to reside in the pre-fetch buffer is to be executed, thepre-fetch threshold may be increased to improve execution performance.In contrast, when a portion of the instruction stream includingdiscontinuities like sub routine calls, unconditional branches, orconditional constructs for which the destination instruction of thediscontinuity is not likely to reside in the pre-fetch buffer (e.g., thepre-fetch buffer is too small to contain the jump and its destination)is to be executed, the pre-fetch threshold may be decreased to reduceenergy consumption. Embodiments disclosed herein include instructionsthat allow the pre-fetch threshold to be programmatically adjusted.

FIG. 1 shows a block diagram of a processor 100 in accordance withvarious embodiments. The processor 100 may be a general purposemicroprocessor, a digital signal processor, a microcontroller, or othercomputing device that executes instructions retrieved from a memorydevice. The processor 100 includes a fetch unit 104, a decode unit 106,and an execution unit 108. The fetch unit 104 retrieves instructionsfrom instruction memory 110, for execution by the processor 100. Thefetch unit 104 provides the retrieved instructions to the decode unit106. The instruction memory 110 may be included in the processor 100, orexternal to the processor 100.

The decode unit 106 examines the instructions received from the fetchunit 104, and translates each instruction into controls suitable foroperating the execution unit 108, processor registers, and othercomponents of the processor 100 to perform operations that effectuatethe instructions. In some embodiments of the processor 100, variousoperations associated with instruction decoding may be performed in thefetch unit 104 or another operational unit of the processor 100. Thedecode unit 106 provides control signals to the execution unit 108, andother units of the processor 100, that cause the processor 100 to carryout the operations needed to execute each instruction.

The execution unit 108 includes arithmetic circuitry, shifters,multipliers, registers, logical operation circuitry, etc. that arearranged to manipulate data values as specified by the control signalsgenerated by the decode unit 106. Some embodiments of the processor 100may include multiple execution units that include the same or differentdata manipulation capabilities.

The processor 100 may include various other components that have beenomitted from FIG. 1 as a matter of clarity. For example, embodiments ofthe processor 100 may include instruction and/or data caches, memory,communication devices, interrupt controllers, timers, clock circuitry,direct memory access controllers, and various other components andperipherals.

The fetch unit 104 includes a pre-fetch unit 102. The pre-fetch unit 102pre-fetches instructions from instruction memory 110 prior to when theinstructions are to be decoded, and stores the instructions until theinstructions are needed for decoding and execution. By pre-fetchinginstructions, the processor 100 can provide stored instructions forexecution without the delays often associated with fetching instructionsfrom a memory device that may be unable to provide instructions at ashigh a rate as the processor 100 is able to execute the instructions.The pre-fetch unit 102 allows the number of instructions pre-fetched andstored for later execution to vary based on pre-fetch thresholdinformation provided via instructions executed by the processor 100.

A software development system that constructs programs for execution bythe processor 100 analyzes jump and branch constructs during programdevelopment, and determines whether and/or how much pre-fetching willbenefit the execution of the program. If pre-fetching will reducepipeline stalls caused by the jump or branch instructions, then thesoftware development system will insert in the instruction set (i.e.,the program) to be executed by the processor 100, instructions that setthe pre-fetch threshold to allow pre-fetching of the jump destinationinstruction. If pre-fetching will not reduce pipeline stalls caused byparticular jump or branch instructions, then the software developmentsystem will insert in the instruction set to be executed by theprocessor 100, instructions that reduce the pre-fetch threshold toreduce energy consumed by pre-fetching instructions that will not beexecuted.

FIG. 2 shows a block diagram of the pre-fetch unit 102 in accordancewith various embodiments. The pre-fetch unit 102 includes instructionstorage 202 and pre-fetch control logic 204. The instruction storage 202includes an array of storage cells, such as registers and/or memorydevices that store instructions retrieved from the instruction memory110. Instructions stored in the instruction storage 202 are provided tothe decoder 106 for execution by the execution unit 108. The instructionstorage 202 may include storage for any number of instructions. Forexample, embodiments of the instruction storage 202 may store 16, 32,64, 128, or another number of instruction words. Similarly, the storagecells of the instruction storage 202 may be of any width needed to storeinstructions executed by the processor 100. For example, the storagecells may be 16 bits in width if the processor 100 executes instructionsthat are 16-bits (or a multiple of 16-bits) in width. Similarly, thestorage cells may be 32 bits in width if the processor 100 executionsinstructions that are 32-bits (or a multiple of 32 bits) in width, etc.As instructions are pre-fetched, the pre-fetched instructions may besequentially stored in the instruction storage 202.

The pre-fetch control logic 204 is coupled to the instruction storage202, and controls pre-fetching of instructions from instruction memory110, storing of pre-fetched instructions in the instruction storage 202,and reading of instructions from the instruction storage 202 forexecution. The pre-fetch control logic 204 includes read-write controllogic 208 and a pre-fetch threshold register 206 coupled to theread-write control logic 208. The read-write control logic 208 mayincluding address and access control logic for reading and writing tothe instruction storage 202. For example, the read-write control logic208 may include logic to implement reading and writing of a circularbuffer in the instruction storage 202. Storage cells of the circularbuffer may be written/over-written when the contents of the storagecells is provided to the decode unit 106, when the circular buffer isflushed due to a flow direction requiring instructions not already inthe buffer, etc.

The read-write control logic 208 may also include pre-fetch address andcontrol logic for triggering fetch operations by the fetch unit 104 forfetching of instructions that are to be stored in the instructionstorage 202 (i.e., pre-fetching instructions). For example, when storagecells of a circular buffer formed in the instruction storage 202 areavailable to be written/over-written, the read-write control logic 208may trigger the fetch unit 104 to fetch instructions to be written tothe buffer.

The pre-fetch threshold register 206 limits the number of instructionspre-fetched and stored in the instruction storage 202 in accordance witha pre-fetch threshold value stored in the pre-fetch threshold register206. For example, a pre-fetch threshold value stored in the pre-fetchthreshold register 206 may control the number of instruction words thatcan be pre-fetched and stored in the instruction storage 202 in advanceof execution. If the pre-fetch threshold value specifies that only a fewinstruction words ahead of an instruction currently being executed maybe pre-fetched and stored in the instruction storage, the number ofpre-fetch cycles wasted when a program discontinuity causes the bufferto be flushed is reduced. If the pre-fetch threshold value specifiespre-fetching of a greater number of instruction words, then stall cycleswill be reduced if the instruction storage contains the pre-fetcheddestination instruction associated with an executed jump or branchinstruction. Similarly, specifying pre-fetching of a greater number ofinstruction words can reduce stall cycles for linear code fetched from aslow instruction memory, which adds bus stall cycles at high clockfrequencies.

In some embodiments of the pre-fetch control logic 204, the pre-fetchthreshold value stored in the pre-fetch threshold register 206 controlsthe number of instruction words pre-fetched by setting a maximum offsetbetween a read pointer that controls instructions read from theinstruction storage 202 and a write pointer that controls instructionswritten to the instruction storage 202. In other embodiments of thepre-fetch control logic 204, the pre-fetch threshold value controls thenumber of instruction words pre-fetched by setting the number of storagecells of the instruction storage 202 included in a circular buffer thatstores pre-fetched instruction words.

The pre-fetch threshold value stored in the pre-fetch threshold register206 is provided via an instruction executed by the processor 100. Apipeline element (e.g., the decode unit 106 or execution unit 108)identifies an instruction passing through the pipeline that sets thepre-fetch threshold value, extracts the pre-fetch threshold value fromthe instruction, and provides the pre-fetch threshold value to thepre-fetch unit for storage in the pre-fetch threshold register 206. Whenthe pre-fetch threshold value stored in the pre-fetch threshold register206 changes, the number of instructions, sequentially following acurrently executing instruction, that are pre-fetched changes.

Some embodiments of the processor 100 can decode and executeinstructions of various lengths. For example, the decode unit 106 maydecode instructions that are 16 bits in length and instructions that are32 bit in length. To reduce overhead associated with execution ofinstructions that set a pre-fetch threshold, the decode unit 106 maysimultaneously process a pre-fetch threshold instruction and anotherinstruction. For example, a 16 bit pre-fetch threshold instruction maybe simultaneously decoded with another 16 bit instruction if the decodeunit 106 can receive and decode 32 bit instructions. The decode unit 106may provide the pre-fetch threshold value to the pre-fetch unit 102.Thus, the processor 100 may provide instruction based pre-fetchthreshold adjustment with little or no additional execution cycleoverhead.

FIG. 3 shows an exemplary instruction 300 for controlling pre-fetchthreshold in accordance with various embodiments. In some embodiments,the instruction 300 may be dedicated to setting the pre-fetch threshold(i.e., a command code dedicated to setting pre-fetch threshold). Inother embodiments, the instruction 300 may be a general-purposeinstruction, such as a load or store instruction, that loads a valueinto a register (e.g., the pre-fetch threshold register), where thepre-fetch threshold register is, for example, memory mapped. In otherembodiments, the instruction 300 may be any instruction executable bythe processor 100 that includes a field that is used to transferpre-fetch threshold information.

The instruction 300 includes a THRES field 302 that specifies thepre-fetch threshold value to be applied in the pre-fetch unit 102. TheTHRES field 302 may contain a coded value that indicates a maximumnumber of instruction words to be pre-fetched. For example, a single bitTHRES field 302 may be used, where a “1” indicates that the maximumnumber of instruction words to be pre-fetched corresponds to the maximumnumber of instruction words storable in the instruction storage 202 (orany predetermined number of instruction words), and a “0” indicates thatno (or any predetermined number of) instruction words are to bepre-fetched. In some embodiments, the THRES field 302 may contain avalue that specifies a number of instruction words to be pre-fetched. Inother embodiments, the pre-fetch threshold value may be encoded in thecommand code 304 of the instruction 300 or in another field of theinstruction 300. In some embodiments of the processor 100, the executionunit 108 or other pipeline element may extract the value from the THRESfield 302 and apply further processing to the value prior to providingthe value to the pre-fetch unit 102. For example, decoding may beapplied to the value provided in the THRES field 302, and the decodedvalue provided to the pre-fetch unit 102.

FIG. 4 shows an instruction sequence 400 that includes a pre-fetchthreshold set to optimize performance in accordance with variousembodiments. The instruction stream 400 includes a pre-fetch thresholdinstruction 402, jump instructions 404 and 408, and jump destinationinstructions 406 and 410. Instruction 406 is the destination of jumpinstruction 404, and instruction 410 is the destination of jump 408.While the instruction sequence 400 is under development, the softwaredevelopment system analyzes the sequence and identifies instructions404, 406, 408, and 410. The software development system computes thedistances between the various jump and destination instructions, anddetermines whether the instruction storage 202 is large enough to storepre-fetched instructions encompassing jump instructions 404, 408 andjump destination instructions 406, 410. If the instruction storage 202is large enough to store, for example, 16 instruction words, and thejump instruction 404 through the destination instruction 410 includes 8instruction words, then software development system may determine thatthe sequence from jump instruction 404 to destination instruction 410can be pre-fetched to improve execution efficiency. Accordingly, thesoftware development system can insert pre-fetch threshold instruction402 in the instruction sequence ahead of the jump instruction 404, wherethe pre-fetch threshold instruction 402 specifies a pre-fetch thresholdvalue large enough to allow the sequence from the jump instruction 404through the destination instruction 410 to be pre-fetched and stored inthe instruction storage 202. The pre-fetch threshold instruction 402sets a pre-fetch threshold of 16 instruction words (e.g., the entireinstruction storage 202). In other embodiments, the pre-fetch thresholdinstruction 402 may set the pre-fetch threshold to a different value(e.g., 8, 12, etc.).

FIG. 5 shows an instruction sequence 500 that includes a pre-fetchthreshold set to reduce pre-fetch energy use in accordance with variousembodiments. The instruction stream 500 includes a pre-fetch thresholdinstruction 502, jump instruction 504, and jump destination instruction506. While the instruction sequence 500 is under development, thesoftware development system analyzes the sequence and identifiesinstructions 504 and 506. The software development system computes thedistance between instructions 504 and 506, and determines whether theinstruction storage 202 is large enough to store pre-fetchedinstructions encompassing instructions 504 and 506. If the instructionstorage 202 is large enough to store, for example, 16 instruction words,and the jump instruction 504 through the destination instruction 506includes 200 instruction words, then the software development system maydetermine that the sequence from jump instruction 504 to destinationinstruction 506 cannot be pre-fetched to improve execution efficiency.Accordingly, the software development system can insert pre-fetchthreshold instruction 502 in the instruction sequence ahead of the jumpinstruction 504, where the pre-fetch threshold instruction 502 specifiesa pre-fetch threshold value small enough to reduce extraneouspre-fetching of instructions between instruction 504 and instruction 506that may not be executed. Thus, the relatively small pre-fetch thresholdspecified by instruction 502 may save the energy associated withpre-fetching instructions that are not executed. The pre-fetch thresholdinstruction 502 sets a pre-fetch threshold of 4 instruction words. Inother embodiments, the pre-fetch threshold instruction 402 may set thepre-fetch threshold to a different value (e.g., 2, 0, half theinstruction storage, etc.).

FIG. 6 shows a flow diagram for a method 600 for setting pre-fetchthresholds in accordance with various embodiments. Though depictedsequentially as a matter of convenience, at least some of the actionsshown can be performed in a different order and/or performed inparallel. Additionally, some embodiments may perform only some of theactions shown. At least some of the operations of the method 600 may beperformed by a processor executing instructions retrieved from anon-transitory computer readable storage medium.

In block 602, a software program executable by the processor 100 isunder development. A tool of a software development system, e.g., acompiler, assembler, or other tool, analyzes instructions of the programand identifies jump or branch instructions and the destinationinstructions associated with a break in program flow caused by executionof the jump or branch instructions.

In block 604, the tool determines the distance (offset or number ofinstruction words) between the identified jump or branch instructionsand the associated destination instructions. In some embodiments, wherejump instructions are in close proximity, the tool may determine thedistance between a jump instruction and a destination instruction of asubsequent jump instruction.

In block 606, the tool determines whether the distance is greater thanthe number of instructions/instruction words that can be stored in theinstruction storage 202 of the pre-fetch unit 102.

If the distance exceeds the capacity of the instruction storage 202,then, in block 608, the tool inserts into the instruction sequence apre-fetch threshold instruction that sets the pre-fetch threshold of thepre-fetch unit 102 to a relatively low value (e.g., 0, 2, 4, etc.).

If the distance does not exceed the capacity of the instruction storage202, then, in block 610, the tool inserts into the instruction sequencea pre-fetch threshold instruction that sets the pre-fetch threshold ofthe pre-fetch unit 102 to a relatively high value (e.g., a value largeenough to allow storage of the instructions from the jump through thejump destination).

In block 612, the tool identifies a set of successive (i.e., adjacent)instructions in the instruction stream generated by the tool. The set ofsuccessive instructions lack flow redirection instructions (jump, call,etc.) and therefore will be sequentially executed by the processor 100.If the number of successive sequentially executed instructions isgreater than a predetermined value, then, in block 614, the tool insertsinto the instruction sequence a pre-fetch threshold instruction thatsets the pre-fetch threshold of the pre-fetch unit 102 to a relativelyhigh value (maximum pre-fetch). Setting the pre-fetch threshold to ahigh value may accelerate execution of the set of successiveinstructions by reducing pipeline stalls associated with retrieving theinstructions from memory.

The tool may analyze the entirety of the software program underdevelopment in accordance with the operations of blocks 602 to 614. Forexample, each program discontinuity (jump, call, etc.) in the softwareprogram may be processed in accordance with blocks 602-610 and each setof successive sequentially executed instructions of the software programmay be processed in accordance with blocks 612-614.

Because the analysis and control of the pre-fetch threshold is performedat program build time rather than program run time, the processor 100need not include logic for determining whether the pre-fetch thresholdshould be increased or decreased to best accommodate conditionalconstructs. Accordingly, embodiments of the processor 100 may be lesscostly and more power efficient than processors that analyzeinstructions for setting the pre-fetch threshold at run time.

In block 616, the processor 100 is executing the program. The processor100 is pre-fetching instructions from the instruction memory 100,storing instructions in the instruction storage 202, readinginstructions from the instruction storage 202, and providing thepre-fetched instructions read from the instruction storage 202 forexecution.

In block 618, a pipeline element (e.g., decode unit 106 or executionunit 108) of the processor 100 identifies a pre-fetch thresholdinstruction that is being executed. For example, the command code of theinstruction is identified. The pipeline element extracts a pre-fetchthreshold value from the identified instruction, and provides thepre-fetch threshold value to the pre-fetch unit 102.

In block 620, the pre-fetch unit sets the pre-fetch threshold based onthe pre-fetch threshold value. That is, the pre-fetch unit 102 sets thenumber of instruction words that can be pre-fetched from instructionmemory 110 and stored in the instruction storage in accordance with thepre-fetch threshold value.

FIG. 7 shows a block diagram of a system 700 for setting pre-fetchthresholds in a set of instructions under development in accordance withvarious embodiments. The system 700 includes a processor 702 and storage704. The processor 702 is communicatively coupled to the storage 704.The processor 702 may be a general-purpose microprocessor, a digitalsignal processor, a microcontroller, or other device capable ofexecuting instructions retrieved from a computer-readable storagemedium. Processor architectures generally include execution units (e.g.,fixed point, floating point, integer, etc.), storage (e.g., registers,memory, etc.), instruction decoding, peripherals (e.g., interruptcontrollers, timers, direct memory access controllers, etc.),input/output systems (e.g., serial ports, parallel ports, etc.) andvarious other components and sub-systems.

The storage 704 is a non-transitory computer-readable storage mediumsuitable for storing instructions that are retrieved and executed by theprocessor 702 to perform the functions disclosed herein. The storage 704may include volatile storage such as random access memory, non-volatilestorage (e.g., a hard drive, an optical storage device (e.g., CD orDVD), FLASH storage, read-only-memory), or combinations thereof.

The system 700 may include other components and subsystems (not shown)such as a display device, input devices, and various interfaces. Thedisplay device may produce images rendered by the processor 702 forviewing by a user of the system 700. The display device may be liquidcrystal display (LCD), an organic light emitting diode (OLED) display, aplasma display, or any other type of display device suitable forproducing images rendered by the processor 702.

An input device is an instrument that can be manipulated by a user tocontrol the system 700. The input device may be a keyboard, a touchpanel integrated with the display device, a pointing device such as amouse, a trackball, a touch pad, a camera-based input device, or anyother instrument suitable for manipulation by a user to operate thesystem 700.

Interfaces suitable for use in the system 700 may include a networkadapter that allows the system 700 to communicate with other devices viawired or wireless networking, multi-media interfaces such as soundgeneration systems, sound capture systems, video capture systems, etc.

In some implementations, the system 700 may be embodied in a computer,such as a desktop computer, a workstation computer, rack mount computer,a notebook computer, or other form of computer known in the art.

The storage 706 includes software development system 706 and softwareprogram under development 710. The program under development 710 is asequence of instructions executable by the processor 100.

The software development system 706 includes tools for generating theprogram under development 710, such as a compiler, an assembler, alinker, etc. The software development system 706 also includes apre-fetch threshold analysis and control tool 708 that analyzes theinstructions of the program under development 710, identifiesconditional constructs including jump and branch instructions and thedestinations of the jump and branch instructions, determines whether thepre-fetch unit 102 can be applied to accelerate execution of theconditional constructs, and inserts pre-fetch threshold instructions inthe program under development 710 to set the pre-fetch threshold appliedby the pre-fetch unit 102 as described herein.

The above discussion is meant to be illustrative of the principles andvarious embodiments of the present invention. Numerous variations andmodifications will become apparent to those skilled in the art once theabove disclosure is fully appreciated. It is intended that the followingclaims be interpreted to embrace all such variations and modifications.

What is claimed is:
 1. A processor, comprising: an execution pipelineconfigured to execute instructions, the execution pipeline comprising adecode unit configured to decode instructions for execution; aninstruction pre-fetch unit coupled to the execution pipeline, theinstruction pre-fetch unit comprising: instruction storage to storepre-fetched instructions that includes a plurality of storage cells; andpre-fetch control logic configured to: fetch instructions from a memoryand store the fetched instructions in the instruction storage; provideinstructions stored in the instruction storage to the execution pipelinefor execution; selectably set a number of instruction words to bepre-fetched for subsequent execution in the execution pipeline in asubsequent fetch operation to be a pre-fetch threshold value encodedwithin a command code contained in a command field of a pre-fetchthreshold instruction by controlling a number of the plurality ofstorage cells of the instruction storage included in a pre-fetch buffer;and insert a second instruction that, when executed by the processor,varies the number of instruction words to be pre-fetched based on adistance between a jump instruction and a destination instruction;wherein the decode unit is configured to: identify, in instructionsretrieved from the instruction storage, the pre-fetch thresholdinstruction; decode the command code of the pre-fetch thresholdinstruction to extract the pre-fetch threshold value; and provide thepre-fetch threshold value to the pre-fetch control logic to set thenumber of instruction words to be pre-fetched; wherein the pre-fetchbuffer is structured as a circular buffer.
 2. The processor of claim 1,wherein the pre-fetch threshold value is selected based upon apercentage of total storage locations of the instruction storage to beused for storage of the fetched instructions.
 3. The processor claim 1,wherein the pre-fetch control logic comprises: a pre-fetch thresholdregister to specify the number of instruction words to be pre-fetched;and instruction storage read-write logic configured to read and writethe instructions to the instruction storage based on a value of thepre-fetch threshold register.
 4. The processor of claim 1, wherein: thecircular buffer of the instruction storage includes a read pointer thatcontrols a read from the instruction storage and a write pointer thatcontrols a write to the instruction storage; and the pre-fetch controllogic is further configured to selectably set the number of instructionwords to be pre-fetched by setting an offset limit between the readpointer and the write pointer based on the number of instruction wordsto be pre-fetched indicated by the pre-fetch threshold instruction. 5.The processor of claim 1, wherein the decode unit is configured toconcurrently decode the pre-fetch threshold instruction and aninstruction other than the pre-fetch threshold instruction.
 6. Theprocessor of claim 1, wherein the number of instruction words to bepre-fetched for subsequent execution indicated by the pre-fetchthreshold instruction is zero.
 7. The processor of claim 1, wherein thecommand code encodes the pre-fetch threshold value as a percentage ofthe instruction storage.
 8. A method, comprising: pre-fetching, by aprocessor, instructions from an instruction memory; storing, by theprocessor, the instructions, pre-fetched from the instruction memory, ina pre-fetch buffer; reading, by the processor, the instructions from thepre-fetch buffer; providing, by the processor, the instructions, readfrom the pre-fetch buffer, to an execution pipeline for execution;identifying, by a decode unit of the execution pipeline, in theinstructions, an instruction that includes a command field that includesa command code and a pre-fetch threshold value encoded within thecommand code; extracting, by the decode unit, the pre-fetch thresholdvalue from the command code, wherein the pre-fetch threshold indicates aquantity of instruction words to be pre-fetched; providing, by thedecode unit, the pre-fetch threshold value to a pre-fetch unit of theprocessor; setting, by the pre-fetch unit, a maximum number ofinstruction words to be pre-fetched for execution to be the pre-fetchthreshold value provided by the decode unit by controlling a count ofstorage cells included in the pre-fetch buffer; and inserting a secondinstruction that, when executed by the processor, varies the maximumnumber of instruction words to be pre-fetched and stored in thepre-fetch buffer based on a distance between a jump instruction and adestination instruction; wherein the pre-fetch buffer is structured as acircular buffer.
 9. The method of claim 8, wherein the setting is basedon the pre-fetch threshold value.
 10. The method of claim 8, wherein:the instructions are a first set of instructions; the instruction is afirst instruction; and the method further comprises: determining, by asoftware development system, whether a second set of instructionsexecutable by the processor contains a jump instruction and adestination instruction of the jump instruction within a range thatallows the jump instruction and the destination instruction to beconcurrently stored in the pre-fetch buffer; and inserting, by thesoftware development system, into the second set of instructions, asecond instruction that when executed by the processor sets the maximumnumber of instruction words to be pre-fetched such that the jumpinstruction and the destination instruction are concurrently stored inthe pre-fetch buffer.
 11. The method of claim 8, wherein: theinstructions are a first set of instructions; the instruction is a firstinstruction; and the method further comprises: determining, by asoftware development system, whether a second set of instructionsexecutable by the processor contains a jump instruction and adestination instruction of the jump instruction with a range that is toogreat to allow the jump instruction and the destination instruction tobe concurrently stored in the pre-fetch buffer; and inserting, by thesoftware development system, into the second set of instructions, secondinstruction that when executed by the processor sets the maximum numberof instructions words to be pre-fetched such that to correspond to nomore than half a total number of locations of the pre-fetch buffer. 12.The method of claim 8, wherein: the instructions are a first set ofinstructions; the instruction is a first instruction; and the methodfurther comprises: determining, by a software development system,whether a second set of instructions executable by the processorcomprises at least a predetermined number of successive instructions tobe sequentially executed; and inserting, by the software developmentsystem, into the second set of instructions, a second instruction thatwhen executed by the processor sets the maximum number to be at leastthe predetermined number.
 13. The method of claim 8, wherein: thepre-fetch buffer is structured as a circular buffer and includes a readpointer and a write pointer; and the setting of the maximum number ofinstruction words to be pre-fetched includes setting a maximum offsetbetween the read pointer and the write pointer.
 14. An instructionpre-fetch unit, comprising: instruction storage for storing pre-fetchedinstructions that includes a plurality of storage cells; and pre-fetchcontrol logic configured to: fetch instructions from a memory and storethe fetched instructions in the instruction storage; provideinstructions stored in the instruction storage to an execution pipelinefor execution; selectably set a number of instruction words to bepre-fetched for execution subsequent to execution of an instructioncurrently being executed in the execution pipeline in a fetch operationby controlling a number of the plurality of the storage cells includedin a pre-fetch buffer, wherein the number of instruction words to bepre-fetched is based on a pre-fetch threshold value encoded into acommand code contained within a command field of an instruction executedin the execution pipeline; and insert a second instruction that, whenexecuted by the processor, varies the number of instruction words to bepre-fetched based on a distance between a jump instruction and adestination instruction; wherein the fetch operation is subsequent toexecution of the instruction having the pre-threshold value; and whereinthe pre-fetch buffer is structured as a circular buffer.
 15. Theinstruction pre-fetch unit of claim 14, wherein the pre-fetch thresholdvalue is selected as a percentage of total storage locations of theinstruction storage.
 16. The instruction pre-fetch unit claim 14,wherein the pre-fetch control logic comprises: a pre-fetch thresholdregister to specify a maximum number of instruction words to bepre-fetched; and instruction storage read-write logic configured to readand write instructions to the instruction storage based on a value ofthe pre-fetch threshold register.
 17. The instruction pre-fetch unit ofclaim 16, wherein the pre-fetch control logic is configured to: receivethe pre-fetch threshold value from the execution pipeline; store thepre-fetch threshold value in the pre-fetch threshold register; andchange the maximum number of instruction words to be pre-fetched basedon the pre-fetch threshold value.
 18. The instruction pre-fetch unit ofclaim 13, wherein: the plurality of the storage cells included in thepre-fetch buffer are structured as a circular buffer; the circularbuffer includes a read pointer and a write pointer; and the pre-fetchcontrol logic is configured to selectably set the number of instructionwords to be pre-fetched for execution by further setting a maximumoffset between the read pointer and the write pointer.